﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using SSPD;

namespace SSPD_Monitor
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();

            SSPD_Init();
        }

        /// <summary>
        /// Инициализация ССПД, подключение БД
        /// </summary>
        static void SSPD_Init()
        {
            Config.Mask = Params.Mask;
            Config.CfgPath = "SSPD.CFG";

            try
            {
                //загрузка параметров конфигурации
                Config.ReadCFG();      

                DB.InitDB();
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + ex.Message);
                System.Threading.Thread.Sleep(1000);
                SSPD_Init();
            }
        }


        protected override void OnStart(string[] args)
        {

            Console.WriteLine(Params.UserInfo.FIO);

        }

        protected override void OnStop()
        {
        }
    }
}
